﻿using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace 转换
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {

        public Point DownPoint { get; private set; } = new Point(0, 0);
        public bool IsMouseDown { get; private set; } = false;


        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_MouseMove(object sender, MouseEventArgs e)
        {
            if (button.RenderTransform is RotateTransform rotateTransform)
            {
                Point point = e.GetPosition(this);
                rotateTransform.Angle = point.X + point.Y;
            }

            if (button2.RenderTransform is ScaleTransform t)
            {
                Point point = e.GetPosition(this);
                t.ScaleX = (point.X + point.Y) / 200;
                t.ScaleY = (point.X + point.Y) / 200;
            }

            if (button3.RenderTransform is ScaleTransform t2)
            {
                Point point = e.GetPosition(this);
                t2.ScaleX = (point.X + point.Y) / 200;
                t2.ScaleY = (point.X + point.Y) / 200;
            }
        }


        private void Window_MouseMove2(object sender, MouseEventArgs e)
        {
            if (!IsMouseDown) return;

            if (border.RenderTransform is TranslateTransform t)
            {
                Point point = e.GetPosition(this);
                t.X = (point.X - DownPoint.X);
                t.Y = (point.Y - DownPoint.Y);
            }
        }

        private void Window_MouseDown(object sender, MouseButtonEventArgs e)
        {
            IsMouseDown = true;
            DownPoint = e.GetPosition(this);
        }

        private void Window_MouseUp(object sender, MouseButtonEventArgs e)
        {
            IsMouseDown = false;
        }
    }
}